<?php
class Info_noticeAction extends IntesysAction {
	public function _initialize(){
		parent::_initialize();
		$this->dao=D('Info');
		$_POST['site_id']=__SITEID__;	
	}
	public function index(){
		$this->listmap = 'site_id = '.__SITEID__.' and type="notice" and (member_id = '.$this->memberInfo['id'].' or pid=1 )';
        //筛选结果并显示
		$this->initView();
		$this->dao->filter('notice',$this->view);
		
       //获取 筛选或添加 部门，所有员工等数据
       $membergroup=D('Member_group')->getGroup();
       $this->assign('grouplist',$membergroup);
	   
	   if(isset($_GET['keywords'])&&$_GET['keywords']!=''){
			$this->listmap .= ' and ( title like \'%'.$_GET['keywords'].'%\' or content like \'%'.$_GET['keywords'].'%\' ) ';
		}
		
		parent::_list();	
       
       if($_POST['requestType']==10100001){
           die(json_encode(array('notice'=>$list,'statu'=>1)));
       }else{
           $this->display();    
       }
	}
	
	public function edit(){
		if($this->_param('id')){
			$this->info=$this->dao->where('id='.$this->_param('id'))->find();
			$this->display();	
		}	
	}
	public function update(){
		if($this->_get('id')){
            $_POST['id']=$this->_get('id');
            if(isset($_POST['content'])){
                $_POST['content']=str_replace(array("\r\n","\n","\r"),'<br/>',strip_tags($_POST['content']));
            }
			parent::update();
		}else{
			parent::update();
		}
	}
	public function insert(){
        if(IS_POST){
            if($_POST['type']!==0)$_POST['type']='notice';
            $_POST['datetime']=time();
            $_POST['member_id']=session(C('USER_AUTH_KEY'));
            $_POST['content']=str_replace(array("\r\n","\n","\r"),'<br/>',strip_tags($_POST['content']));
            parent::insert();
        }
	}
	public function delete(){
		if($this->_get('id')){
			parent::delete();
		}
	}
}

